using System;
using System.Data;
using Utils;
using Utils.DatabaseUtils;


namespace BDS
{
public class LocationUI
{ 
	private int locationID;
	public int LocationID
	{
		get { return locationID;}
		set { locationID = value;}
	}

	private String locationName;
	public String LocationName
	{
		get { return locationName;}
		set { locationName = value;}
	}

	private String locationAlias;
	public String LocationAlias
	{
		get { return locationAlias;}
		set { locationAlias = value;}
	}

	private int parentID;
	public int ParentID
	{
		get { return parentID;}
		set { parentID = value;}
	}

	private bool isEnable;
	public bool IsEnable
	{
		get { return isEnable;}
		set { isEnable = value;}
	}

	public LocationUI() {}

	public LocationUI(int locationID, String locationName, String locationAlias, int parentID, bool isEnable)
	 {
		this.locationID = locationID;
 		this.locationName = locationName;
 		this.locationAlias = locationAlias;
 		this.parentID = parentID;
 		this.isEnable = isEnable;
 	}

	public int Add(String locationName, String locationAlias, int parentID, bool isEnable)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Location_Add",locationName,locationAlias,parentID,isEnable);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Update(int locationID, String locationName, String locationAlias, int parentID, bool isEnable)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Location_Update",locationID,locationName,locationAlias,parentID,isEnable);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Delete(int locationID)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Location_Delete",locationID);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int DeleteAll()
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Location_DeleteAll");
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public DataSet Get(int locationID)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Location_Get",locationID);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetAll()
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Location_GetAll");
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetByParentID(int parentID)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Location_GetByParentID",parentID);
			return result;
		}
		catch(Exception e) {return null; }
	}

} 
}
